Changed properties to designer file and hiding interval selector when notify push...
authorPablo Ariño Muñoz <progpabarino@gmail.com>
Thu, 27 Feb 2025 17:42:39 +0000 (18:42 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 28 Feb 2025 15:22:36 +0000 (15:22 +0000)
Signed-off-by: Pablo Ariño Muñoz <progpabarino@gmail.com>
src/gui/generalsettings.cpp
src/gui/generalsettings.h
src/gui/generalsettings.ui

index fa4fa9bd2768b1db6e9ab4819f9abb3b3f674323..1110ced254f6d9ccc84e33d9e905ab6b3b4c7808 100644 (file)
@@ -21,6 +21,7 @@
 #include "owncloudsetupwizard.h"
 #include "accountmanager.h"
 #include "guiutility.h"
+#include "capabilities.h"
 
 #if defined(BUILD_UPDATER)
 #include "updater/updater.h"
@@ -187,12 +188,9 @@ GeneralSettings::GeneralSettings(QWidget *parent)
     , _ui(new Ui::GeneralSettings)
 {
     _ui->setupUi(this);
-    
-    _ui->labelInterval->setText("seconds (if <a href=\"https://github.com/nextcloud/notify_push\">Client Push</a> is unavailable)");
-    _ui->labelInterval->setTextFormat(Qt::RichText);
-    _ui->labelInterval->setTextInteractionFlags(Qt::TextBrowserInteraction);
-    _ui->labelInterval->setOpenExternalLinks(true);
 
+    updatePollIntervalVisibility();
+    
     connect(_ui->serverNotificationsCheckBox, &QAbstractButton::toggled,
         this, &GeneralSettings::slotToggleOptionalServerNotifications);
     _ui->serverNotificationsCheckBox->setToolTip(tr("Server notifications that require attention."));
@@ -330,7 +328,8 @@ void GeneralSettings::loadMiscSettings()
     _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
 
     const auto interval = cfgFile.remotePollInterval(); 
-    _ui->remotePollIntervalSpinBox->setValue(static_cast<int>(interval.count() / 1000));  
+    _ui->remotePollIntervalSpinBox->setValue(static_cast<int>(interval.count() / 1000));
+    updatePollIntervalVisibility(); 
 }
 
 #if defined(BUILD_UPDATER)
@@ -660,4 +659,19 @@ void GeneralSettings::slotRemotePollIntervalChanged(int seconds)
     cfgFile.setRemotePollInterval(interval);
 }
 
+void GeneralSettings::updatePollIntervalVisibility() {
+    const auto accounts = AccountManager::instance()->accounts();
+    const auto pushAvailable = std::any_of(accounts.cbegin(), accounts.cend(),
+    [](const AccountStatePtr &accountState) -> bool {
+        if (!accountState)
+            return false;
+        AccountPtr accountPtr = accountState->account();
+        if (!accountPtr)
+            return false;
+        return accountPtr->capabilities().availablePushNotifications().testFlag(PushNotificationType::Files);
+    });
+
+    _ui->horizontalLayoutWidget_remotePollInterval->setVisible(!pushAvailable);
+}
+
 } // namespace OCC
index 7868c489999000de7e1c52a50d715c585729483b..519a40b7fa2a9f3d41133c5acced15a9f7d9a8c2 100644 (file)
@@ -60,6 +60,7 @@ private slots:
     void loadMiscSettings();
     void slotShowLegalNotice();
     void slotRemotePollIntervalChanged(int seconds);
+    void updatePollIntervalVisibility();
 #if defined(BUILD_UPDATER)
     void slotUpdateInfo();
     void slotUpdateChannelChanged();
index 68b53b4a8cf02a48a74d219946602c1dbbda5441..55509ab426e44e862f455a005a54385a09a3aef7 100644 (file)
         </item>
        </layout>
       </item>
-      <item>
-       <layout class="QHBoxLayout" name="horizontalLayout_remotePollInterval">
-        <item>
-         <widget class="QLabel" name="remotePollIntervalLabel">
-          <property name="text">
-           <string>Server poll interval</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QSpinBox" name="remotePollIntervalSpinBox">
-          <property name="minimum">
-            <number>30</number>
-          </property>
-          <property name="maximum">
-           <number>999999</number>
-          </property>
-          <property name="singleStep">
-           <number>1</number>
-          </property>         
-         </widget>         
-        </item>
-        <item>
-         <widget class="QLabel" name="labelInterval">
-          <property name="text">
-           <string extracomment="Trailing part of &quot;Server poll interval&quot; ">seconds (if Client Push is unavailable)</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="horizontalSpacer_remotePollInterval">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>40</width>
-            <height>20</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-       </layout>
-      </item>
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_10">
         <item>
         </item>
        </layout>
       </item>
+      <item>
+       <widget class="QWidget" name="horizontalLayoutWidget_remotePollInterval">
+        <layout class="QHBoxLayout" name="horizontalLayout_remotePollInterval">
+         <item>
+          <widget class="QLabel" name="remotePollIntervalLabel">
+           <property name="text">
+            <string>Server poll interval</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QSpinBox" name="remotePollIntervalSpinBox">
+           <property name="minimum">
+            <number>30</number>
+           </property>
+           <property name="maximum">
+            <number>999999</number>
+           </property>
+           <property name="singleStep">
+            <number>1</number>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QLabel" name="labelInterval">
+           <property name="text">
+            <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;seconds (if &lt;a href=&quot;https://github.com/nextcloud/notify_push&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#2980b9;&quot;&gt;Client Push&lt;/span&gt;&lt;/a&gt; is unavailable)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+           </property>
+           <property name="textFormat">
+            <enum>Qt::TextFormat::RichText</enum>
+           </property>
+           <property name="openExternalLinks">
+            <bool>true</bool>
+           </property>
+           <property name="textInteractionFlags">
+            <set>Qt::TextInteractionFlag::TextBrowserInteraction</set>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer name="horizontalSpacer_remotePollInterval">
+           <property name="orientation">
+            <enum>Qt::Orientation::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+        </layout>
+       </widget>
+      </item>
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_4">
         <item>